<?php

/**
 * +----------------------------------------------------------------------
 * | 后台页面
 * +----------------------------------------------------------------------
 *                                            ...     .............
 *                                          ..   .:!o&*&&&&&ooooo&; .
 *                                        ..  .!*%*o!;.
 *                                      ..  !*%*!.      ...
 *                                     .  ;$$!.   .....
 *                          ........... .*#&   ...
 *                                     :$$: ...
 *                          .;;;;;;;:::#%      ...
 *                        . *@ooooo&&&#@***&&;.   .
 *                        . *@       .@%.::;&%$*!. . .
 *          ................!@;......$@:      :@@$.
 *                          .@!   ..!@&.:::::::*@@*.:..............
 *        . :!!!!!!!!!!ooooo&@$*%%%*#@&*&&&&&&&*@@$&&&oooooooooooo.
 *        . :!!!!!!!!;;!;;:::@#;::.;@*         *@@o
 *                           @$    &@!.....  .*@@&................
 *          ................:@* .  ##.     .o#@%;
 *                        . &@%..:;@$:;!o&*$#*;  ..
 *                        . ;@@#$$$@#**&o!;:   ..
 *                           :;:: !@;        ..
 *                               ;@*........
 *                       ....   !@* ..
 *                 ......    .!%$! ..     | AUTHOR: dfer
 *         ......        .;o*%*!  .       | EMAIL: df_business@qq.com
 *                .:;;o&***o;.   .        | QQ: 3504725309
 *        .;;!o&****&&o;:.    ..          | WEBSITE: http://www.dfer.site
 * +----------------------------------------------------------------------
 *
 */

namespace plugins\dfer_thinkcmf_tools\controller;

use cmf\controller\PluginAdminBaseController;
use think\facade\Db;
use think\helper\Str;
use plugins\dfer_thinkcmf_tools\model\{PluginModel};
use plugins\dfer_thinkcmf_tools\CommonTrait;

class AdminBaseController extends PluginAdminBaseController
{
    use CommonTrait;

    public $config, $adminId, $info, $root;

    protected function initialize()
    {
        parent::initialize();
        $this->root = dirname(__DIR__, 1);
        $this->adminId = cmf_get_current_admin_id();
        $this->assign("admin_id", $this->adminId);

        $this->config = $this->getPlugin()->getConfig();
        $this->assign("config", $this->config);
        $this->info = $this->getPlugin()->info;
        // var_dump($this->config);die;
        $this->info['id'] = PluginModel::where('name', $this->info['name'])->value('id');
        $this->assign("info", $this->info);
    }


    /**
     * 调用视图文件
     * @param {Object} $template 模板名
     */
    protected function fetch($template = '', $vars = [], $replace = [], $config = [])
    {
        //驼峰转下划线
        $template = Str::snake($template);
        return parent::fetch($template);
    }
}
